package com.mmall.controller;


import com.mmall.common.JsonData;
import com.mmall.param.RoleParam;
import com.mmall.service.SysAclService;
import com.mmall.service.SysRoleService;
import com.mmall.service.SysTreeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/sys/role")
public class SysRoleController {

@Autowired
private SysRoleService sysRoleService;
    @Autowired
    private SysTreeService sysTreeService;



    @RequestMapping("role.page")
    public ModelAndView page() {
        return new ModelAndView("role");
    }




    @RequestMapping("/save.json")
    @ResponseBody
    public JsonData saveRole(RoleParam param){

           sysRoleService.save(param);
        return JsonData.success();
    }

    @RequestMapping("/update.json")
    @ResponseBody
    public JsonData updateRole(RoleParam param){

          sysRoleService.update(param);
        return JsonData.success();

    }
    @RequestMapping("/list.json")
    @ResponseBody
    public JsonData list(RoleParam param){


        return JsonData.success(sysRoleService.getAll());
    }


    @RequestMapping("/roleTree.json")
    @ResponseBody
    public JsonData roleTree(@RequestParam("roleId") int roleId) {

        return JsonData.success(sysTreeService.roleTree(roleId));

    }
}
